import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
from datetime import datetime as dt
import plotly.express as px
df = pd.read_csv("Summer22_FootballTransfers.csv")
df.head()
| name | position | age | origin_club | league_origin_club | country_origin_club | new_club | league_new_club | country_new_club | cost | date_of_transfer | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Amine Gouiri | Centre-Forward | 22.0 | OGC Nice | Ligue 1 | France | Stade Rennais FC | Ligue 1 | France | €42.00m | 9/1/2022 |
| 1 | Umar Sadiq | Centre-Forward | 25.0 | UD Almería | LaLiga | Spain | Real Sociedad | LaLiga | Spain | €18.00m | 9/1/2022 |
| 2 | Carlos Soler | Central Midfield | 25.0 | Valencia CF | LaLiga | Spain | Paris Saint-Germain | Ligue 1 | France | €50.00m | 9/1/2022 |
| 3 | Manuel Akanji | Centre-Back | 27.0 | Borussia Dortmund | Bundesliga | Germany | Manchester City | Premier League | England | €30.00m | 9/1/2022 |
| 4 | Wout Faes | Centre-Back | 24.0 | Stade Reims | Ligue 1 | France | Leicester City | Premier League | England | €10.00m | 9/1/2022 |
df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 33625 entries, 0 to 33624 Data columns (total 11 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 name 33620 non-null object 1 position 33615 non-null object 2 age 33477 non-null float64 3 origin_club 33620 non-null object 4 league_origin_club 32685 non-null object 5 country_origin_club 32690 non-null object 6 new_club 33615 non-null object 7 league_new_club 28047 non-null object 8 country_new_club 28051 non-null object 9 cost 33621 non-null object 10 date_of_transfer 33625 non-null object dtypes: float64(1), object(10) memory usage: 2.8+ MB
plt.figure(figsize=(14 , 5))
sns.heatmap(df.isna());
df.isna().sum()
name 5 position 10 age 148 origin_club 5 league_origin_club 940 country_origin_club 935 new_club 10 league_new_club 5578 country_new_club 5574 cost 4 date_of_transfer 0 dtype: int64
df.dropna(inplace= True)
plt.figure(figsize=(14 , 5))
sns.heatmap(df.isna());
df.isna().sum()
name 0 position 0 age 0 origin_club 0 league_origin_club 0 country_origin_club 0 new_club 0 league_new_club 0 country_new_club 0 cost 0 date_of_transfer 0 dtype: int64
df.duplicated().sum()
0
df.head()
| name | position | age | origin_club | league_origin_club | country_origin_club | new_club | league_new_club | country_new_club | cost | date_of_transfer | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Amine Gouiri | Centre-Forward | 22.0 | OGC Nice | Ligue 1 | France | Stade Rennais FC | Ligue 1 | France | €42.00m | 9/1/2022 |
| 1 | Umar Sadiq | Centre-Forward | 25.0 | UD Almería | LaLiga | Spain | Real Sociedad | LaLiga | Spain | €18.00m | 9/1/2022 |
| 2 | Carlos Soler | Central Midfield | 25.0 | Valencia CF | LaLiga | Spain | Paris Saint-Germain | Ligue 1 | France | €50.00m | 9/1/2022 |
| 3 | Manuel Akanji | Centre-Back | 27.0 | Borussia Dortmund | Bundesliga | Germany | Manchester City | Premier League | England | €30.00m | 9/1/2022 |
| 4 | Wout Faes | Centre-Back | 24.0 | Stade Reims | Ligue 1 | France | Leicester City | Premier League | England | €10.00m | 9/1/2022 |
df.date_of_transfer.unique()
array(['9/1/2022', '8/31/2022', '8/30/2022', '8/29/2022', '8/28/2022',
'8/27/2022', '8/26/2022', '8/25/2022', '8/24/2022', '8/23/2022',
'8/22/2022', '8/21/2022', '8/20/2022', '8/19/2022', '8/18/2022',
'8/17/2022', '8/16/2022', '8/15/2022', '8/14/2022', '8/13/2022',
'8/12/2022', '8/11/2022', '8/10/2022', '8/9/2022', '8/8/2022',
'8/7/2022', '8/6/2022', '8/5/2022', '8/4/2022', '8/3/2022',
'8/2/2022', '8/1/2022', '7/31/2022', '7/30/2022', '7/29/2022',
'7/28/2022', '7/27/2022', '7/26/2022', '7/25/2022', '7/24/2022',
'7/23/2022', '7/22/2022', '7/21/2022', '7/20/2022', '7/19/2022',
'7/18/2022', '7/17/2022', '7/16/2022', '7/15/2022', '7/14/2022',
'7/13/2022', '7/12/2022', '7/11/2022', '7/10/2022', '7/9/2022',
'7/8/2022', '7/7/2022', '7/6/2022', '7/5/2022', '7/4/2022',
'7/3/2022', '7/2/2022', '7/1/2022'], dtype=object)
df.cost.replace("€" , " ")
0 €42.00m
1 €18.00m
2 €50.00m
3 €30.00m
4 €10.00m
...
33619 €100Th.
33621 €10Th.
33622 €10Th.
33623 €10Th.
33624 €25Th.
Name: cost, Length: 27027, dtype: object
cost = []
for i in df.cost:
i = i[1:-1].replace("Th", "")
cost.append(i)
cost
['42.00', '18.00', '50.00', '30.00', '10.00', '28.00', '18.00', '15.00', '6.00', '12.00', '7.00', '16.00', '6.50', '3.00', '7.00', '12.00', '6.00', '5.00', '8.00', '18.00', '10.00', '5.00', '5.00', '27.00', '12.00', '7.00', '3.50', '6.00', '18.00', '2.00', '10.00', '1.50', '4.00', '18.00', '3.00', '1.60', '500', '7.00', '12.00', '900', '2.00', '500', '150', '200', '250', '200', '5.00', '450', '1.00', '3.00', '3.00', '400', '1.80', '1.20', '500', '400', '50', '2.00', '200', '200', '200', '500', '250', '4.00', '200', '225', '25', '50', '600', '125', '1.20', '750', '1.00', '25', '300', '1.50', '300', '100', '6.00', '1.00', '275', '250', '225', '300', '1.40', '7.00', '600', '100', '400', '4.00', '500', '300', '1.50', '400', '700', '400', '1.80', '200', '50', '50', '1.00', '50', '75', '300', '20.00', '200', '100', '200', '275', '75', '75', '2.50', '300', '2.00', '300', '100', '125', '200', '150', '500', '250', '4.00', '100', '50', '500', '2.00', '600', '300', '75', '1.20', '800', '50', '200', '75', '200', '15.00', '100', '600', '250', '500', '50', '2.50', '25', '125', '300', '50', '500', '400', '50', '100', '125', '3.50', '275', '600', '200', '250', '25', '400', '200', '100', '175', '1.00', '150', '150', '50', '350', '25', '50', '100', '100', '25', '125', '100', '100', '600', '100', '10', '75', '50', '300', '50', '400', '200', '125', '10', '25', '25', '200', '75', '275', '1.00', '3.00', '75', '50', '150', '50', '50', '100', '100', '50', '125', '125', '250', '6.00', '50', '10', '25', '175', '25', '100', '200', '200', '100', '250', '75', '50', '100', '300', '10', '50', '500', '25', '25', '75', '100', '600', '400', '150', '10', '50', '10', '50', '125', '300', '200', '300', '25', '25', '50', '100', '100', '75', '500', '150', '200', '150', '75', '100', '100', '50', '10', '10', '25', '10', '50', '25', '100', '10', '10', '100', '150', '25', '25', '50', '25', '25', '50', '10', '10', '2.80', '375', '225', '600', '200', '5.00', '1.00', '4.00', '25', '200', '325', '250', '200', '100', '200', '5.00', '5.00', '600', '400', '75', '1.50', '175', '300', '7.00', '500', '5.00', '1.40', '500', '2.00', '250', '200', '3.00', '6.00', '1.50', '2.00', '22.00', '300', '75', '3.50', '750', '4.50', '1.50', '400', '18.00', '10.00', '200', '400', '1.20', '1.80', '1.20', '6.00', '22.00', '3.00', '1.10', '10.00', '450', '200', '7.00', '400', '600', '17.00', '3.00', '1.50', '10.00', '750', '150', '550', '1.80', '800', '900', '400', '400', '150', '150', '500', '800', '1.80', '18.00', '2.80', '400', '4.00', '500', '10', '1.40', '400', '375', '450', '3.50', '900', '5.00', '900', '1.00', '500', '1.00', '1.50', '700', '150', '200', '18.00', '75', '5.00', '10.00', '350', '2.00', '200', '700', '275', '700', '200', '13.00', '300', '1.00', '150', '1.50', '4.50', '100', '2.50', '150', '600', '7.00', '150', '300', '600', '125', '500', '2.00', '175', '1.30', '200', '100', '800', '400', '300', '2.00', '600', '50', '500', '50', '200', '200', '650', '3.50', '300', '350', '3.00', '200', '1.00', '200', '1.80', '1.20', '1.80', '150', '300', '1.50', '250', '2.00', '250', '600', '600', '50', '2.00', '150', '150', '800', '900', '400', '800', '700', '200', '200', '7.00', '100', '150', '50', '200', '400', '400', '400', '300', '200', '225', '100', '100', '25', '150', '600', '500', '5.00', '500', '9.00', '700', '50', '25', '300', '100', '125', '500', '200', '150', '75', '500', '500', '2.00', '500', '400', '50', '1.80', '200', '2.00', '250', '150', '200', '50', '125', '475', '75', '150', '100', '25', '800', '200', '10', '150', '800', '150', '400', '500', '50', '100', '8.00', '12.00', '2.50', '4.50', '200', '500', '150', '750', '100', '450', '400', '100', '50', '75', '100', '1.50', '400', '175', '10', '10', '1.30', '200', '10', '125', '150', '300', '600', '250', '200', '300', '600', '50', '2.00', '150', '1.00', '400', '2.50', '10', '250', '50', '50', '1.00', '500', '150', '300', '250', '150', '200', '250', '400', '300', '100', '50', '400', '50', '600', '300', '2.50', '40.00', '25.00', '7.00', '9.00', '4.50', '25.00', '1.50', '2.80', '9.00', '800', '6.00', '11.00', '2.00', '1.50', '400', '2.00', '1.50', '800', '3.50', '700', '200', '2.00', '500', '700', '9.00', '1.30', '1.00', '4.00', '400', '6.00', '2.50', '600', '700', '125', '350', '50', '50', '100', '400', '50', '50', '100', '100', '250', '300', '1.20', '800', '50', '175', '200', '125', '400', '700', '250', '350', '1.10', '125', '2.50', '100', '400', '200', '1.50', '150', '1.50', '250', '500', '250', '50', '50', '175', '17.00', '225', '12.00', '400', '600', '600', '2.00', '2.00', '100', '50', '50', '100', '300', '75', '50', '25', '800', '8.00', '400', '175', '25', '250', '250', '350', '100', '250', '75', '50', '2.50', '150', '50', '50', '200', '275', '75', '300', '300', '200', '600', '25', '200', '200', '600', '100', '300', '75', '200', '500', '200', '175', '150', '50', '75', '300', '75', '500', '50', '100', '100', '150', '200', '200', '300', '100', '150', '100', '50', '75', '100', '125', '50', '500', '400', '150', '600', '250', '200', '25', '100', '25', '25', '75', '25', '25', '400', '175', '125', '150', '700', '200', '50', '50', '175', '125', '250', '75', '50', '125', '100', '150', '10', '25', '200', '350', '200', '100', '175', '10', '100', '100', '100', '25', '10', '350', '50', '200', '75', '25', '175', '50', '50', '75', '50', '300', '200', '50', '25', '50', '300', '25', '10', '300', '200', '600', '25', '25', '50', '150', '25', '50', '50', '25', '25', '100', '50', '100', '300', '25', '400', '50', '10', '10', '100', '400', '50', '25', '100', '25', '150', '10', '175', '25', '75', '100', '50', '300', '100', '100', '200', '150', '75', '25', '50', '75', '250', '10', '50', '600', '100', '50', '25', '25', '10', '10', '100', '50', '250', '200', '10', '75', '10', '50', '25', '10', '600', '250', '450', '800', '800', '1.50', '700', '500', '250', '375', '400', '125', '900', '400', '700', '350', '3.00', '3.00', '2.50', '350', '75', '350', '2.50', '300', '300', '300', '2.20', '1.50', '1.00', '75', '75', '650', '700', '300', '5.00', '25', '100', '200', '100', '500', '275', '250', '75', '1.20', '400', '500', '600', '25', '250', '2.00', '10', '100', '25', '200', '2.80', '150', '250', '400', '200', '125', '300', '250', '1.50', '200', '700', '6.00', '350', '1.80', '350', '250', '5.00', '700', '500', '300', '800', '600', '850', '325', '1.50', '1.20', '50', '350', '175', '1.20', '100', '450', '4.50', '8.00', '3.00', '1.20', '250', '400', '250', '100', '100', '450', '4.00', '750', '25', '450', '200', '600', '1.00', '10.00', '50', '700', '10', '100', '100', '700', '150', '15.00', '4.00', '25', '450', '150', '800', '400', '150', '500', '50', '800', '200', '550', '800', '1.00', '100', '100', '3.00', '25', '100', '200', '50', '600', '25', '25', '100', '300', '200', '25', '350', '3.00', '100', '400', '10', '125', '100', '50', '250', '50', '400', '25', '150', '50', '300', '200', '200', '2.50', '50', '200', '600', '300', '150', '25', '500', '300', '25', '50', '200', '100', '50', '50', '200', '75', '100', '10', '100', '100', '10', '500', ...]
df["cost"] = cost
df["cost"] = df["cost"].astype('float')
df.head()
| name | position | age | origin_club | league_origin_club | country_origin_club | new_club | league_new_club | country_new_club | cost | date_of_transfer | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Amine Gouiri | Centre-Forward | 22.0 | OGC Nice | Ligue 1 | France | Stade Rennais FC | Ligue 1 | France | 42.0 | 9/1/2022 |
| 1 | Umar Sadiq | Centre-Forward | 25.0 | UD Almería | LaLiga | Spain | Real Sociedad | LaLiga | Spain | 18.0 | 9/1/2022 |
| 2 | Carlos Soler | Central Midfield | 25.0 | Valencia CF | LaLiga | Spain | Paris Saint-Germain | Ligue 1 | France | 50.0 | 9/1/2022 |
| 3 | Manuel Akanji | Centre-Back | 27.0 | Borussia Dortmund | Bundesliga | Germany | Manchester City | Premier League | England | 30.0 | 9/1/2022 |
| 4 | Wout Faes | Centre-Back | 24.0 | Stade Reims | Ligue 1 | France | Leicester City | Premier League | England | 10.0 | 9/1/2022 |
df["date_of_transfer"] = pd.to_datetime(df["date_of_transfer"])
df["date_of_transfer"] = df["date_of_transfer"].dt.strftime("%b")
df.rename(columns={"date_of_transfer" : "month"} , inplace= True)
df.head()
| name | position | age | origin_club | league_origin_club | country_origin_club | new_club | league_new_club | country_new_club | cost | month | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Amine Gouiri | Centre-Forward | 22.0 | OGC Nice | Ligue 1 | France | Stade Rennais FC | Ligue 1 | France | 42.0 | Sep |
| 1 | Umar Sadiq | Centre-Forward | 25.0 | UD Almería | LaLiga | Spain | Real Sociedad | LaLiga | Spain | 18.0 | Sep |
| 2 | Carlos Soler | Central Midfield | 25.0 | Valencia CF | LaLiga | Spain | Paris Saint-Germain | Ligue 1 | France | 50.0 | Sep |
| 3 | Manuel Akanji | Centre-Back | 27.0 | Borussia Dortmund | Bundesliga | Germany | Manchester City | Premier League | England | 30.0 | Sep |
| 4 | Wout Faes | Centre-Back | 24.0 | Stade Reims | Ligue 1 | France | Leicester City | Premier League | England | 10.0 | Sep |
df.month.unique()
array(['Sep', 'Aug', 'Jul'], dtype=object)
sort = df.groupby("new_club").name.count().sort_values(ascending= False)
sort
new_club
Potenza Calcio 26
SKA Khabarovsk 23
Piacenza Calcio 1919 23
HNK Rijeka 23
Delfino Pescara 1936 23
..
Racing Besançon 1
FC Luzern U21 1
Rabat Ajax 1
RZ Deportivo Aragón 1
Ünye 1957 Spor 1
Name: name, Length: 6141, dtype: int64
club_df = pd.DataFrame(df.groupby("new_club").name.count().sort_values(ascending= False).index)
club_df["count_of_trans"] = sort.values
club_df = club_df[:10]
club_df
| new_club | count_of_trans | |
|---|---|---|
| 0 | Potenza Calcio | 26 |
| 1 | SKA Khabarovsk | 23 |
| 2 | Piacenza Calcio 1919 | 23 |
| 3 | HNK Rijeka | 23 |
| 4 | Delfino Pescara 1936 | 23 |
| 5 | Rotor Volgograd | 23 |
| 6 | AC Monza | 23 |
| 7 | US Cremonese | 23 |
| 8 | US Lecce | 22 |
| 9 | RFK Novi Sad 1921 | 22 |
def bar( data , xvar , yvar , figsize=[15, 7]):
if figsize:
plt.figure(figsize=figsize)
plt.bar(data= data , x= xvar , height= yvar)
plt.xlabel(f"{xvar}" , fontsize = 20 , fontweight = "bold")
plt.ylabel(f"{yvar}" , fontsize = 20 , fontweight = "bold")
plt.xticks(rotation= 90)
for i in range(len(data[f"{xvar}"])):
plt.text(i , data[f"{yvar}"][i] , data[f"{yvar}"][i] ,
ha= "center" ,
va= "bottom" ,
fontsize = "12" ,
fontweight = "bold")
plt.show()
bar(club_df , "new_club" , "count_of_trans")
df.head()
| name | position | age | origin_club | league_origin_club | country_origin_club | new_club | league_new_club | country_new_club | cost | month | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Amine Gouiri | Centre-Forward | 22.0 | OGC Nice | Ligue 1 | France | Stade Rennais FC | Ligue 1 | France | 42.0 | Sep |
| 1 | Umar Sadiq | Centre-Forward | 25.0 | UD Almería | LaLiga | Spain | Real Sociedad | LaLiga | Spain | 18.0 | Sep |
| 2 | Carlos Soler | Central Midfield | 25.0 | Valencia CF | LaLiga | Spain | Paris Saint-Germain | Ligue 1 | France | 50.0 | Sep |
| 3 | Manuel Akanji | Centre-Back | 27.0 | Borussia Dortmund | Bundesliga | Germany | Manchester City | Premier League | England | 30.0 | Sep |
| 4 | Wout Faes | Centre-Back | 24.0 | Stade Reims | Ligue 1 | France | Leicester City | Premier League | England | 10.0 | Sep |
df.league_new_club.nunique()
461
sort = df.groupby("league_new_club").name.count().sort_values(ascending= False)
sort
league_new_club
Italy 798
Spain 486
Liga 2 416
Premier Liga 342
Romania 332
...
Kolmonen Etelä C 1
Landesliga Hansa 1
VL Hessen-Mitte 1
Finland 1
Réunion 1
Name: name, Length: 461, dtype: int64
league_df = pd.DataFrame(sort.index)
league_df["count_of_trans"] = sort.values
league_df = league_df[:10]
league_df
| league_new_club | count_of_trans | |
|---|---|---|
| 0 | Italy | 798 |
| 1 | Spain | 486 |
| 2 | Liga 2 | 416 |
| 3 | Premier Liga | 342 |
| 4 | Romania | 332 |
| 5 | Premier League | 326 |
| 6 | Serie C - C | 315 |
| 7 | League One | 299 |
| 8 | Serie B | 297 |
| 9 | Serbia | 290 |
bar(league_df , "league_new_club" , "count_of_trans")
df.head(2)
| name | position | age | origin_club | league_origin_club | country_origin_club | new_club | league_new_club | country_new_club | cost | month | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Amine Gouiri | Centre-Forward | 22.0 | OGC Nice | Ligue 1 | France | Stade Rennais FC | Ligue 1 | France | 42.0 | Sep |
| 1 | Umar Sadiq | Centre-Forward | 25.0 | UD Almería | LaLiga | Spain | Real Sociedad | LaLiga | Spain | 18.0 | Sep |
df.head()
| name | position | age | origin_club | league_origin_club | country_origin_club | new_club | league_new_club | country_new_club | cost | month | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Amine Gouiri | Centre-Forward | 22.0 | OGC Nice | Ligue 1 | France | Stade Rennais FC | Ligue 1 | France | 42.0 | Sep |
| 1 | Umar Sadiq | Centre-Forward | 25.0 | UD Almería | LaLiga | Spain | Real Sociedad | LaLiga | Spain | 18.0 | Sep |
| 2 | Carlos Soler | Central Midfield | 25.0 | Valencia CF | LaLiga | Spain | Paris Saint-Germain | Ligue 1 | France | 50.0 | Sep |
| 3 | Manuel Akanji | Centre-Back | 27.0 | Borussia Dortmund | Bundesliga | Germany | Manchester City | Premier League | England | 30.0 | Sep |
| 4 | Wout Faes | Centre-Back | 24.0 | Stade Reims | Ligue 1 | France | Leicester City | Premier League | England | 10.0 | Sep |
aa = df.new_club.value_counts()
index = df.new_club.value_counts().index[:10]
values = df.new_club.value_counts().values[:10]
values
array([26, 23, 23, 23, 23, 23, 23, 23, 22, 22], dtype=int64)
plt.figure(figsize=(15, 7))
plt.bar(x= index , height= values)
plt.xlabel( "Club", fontsize = 20 , fontweight = "bold")
plt.ylabel( "Count of buying Players", fontsize = 20 , fontweight = "bold")
plt.xticks(rotation= 90)
for i in range(len(index)):
plt.text(i , values[i] , values[i] ,
ha= "center" ,
va= "bottom" ,
fontsize = "12" ,
fontweight = "bold")
plt.show()
sort = df.groupby("new_club").cost.sum().sort_values(ascending= False)
sort
new_club
Reggina 1914 8254.7
APOEL Nicosia 7327.0
HNK Rijeka 7289.7
Quevilly Rouen Métropole 7201.0
Delfino Pescara 1936 7151.2
...
Leeds United U21 1.2
Getafe CF B 1.0
Chelsea FC U21 1.0
Portland Timbers 1.0
CD Palestino 1.0
Name: cost, Length: 6141, dtype: float64
rich_club = pd.DataFrame(sort.index)
rich_club["cost"] = sort.values
rich_club = rich_club[:10]
rich_club
| new_club | cost | |
|---|---|---|
| 0 | Reggina 1914 | 8254.7 |
| 1 | APOEL Nicosia | 7327.0 |
| 2 | HNK Rijeka | 7289.7 |
| 3 | Quevilly Rouen Métropole | 7201.0 |
| 4 | Delfino Pescara 1936 | 7151.2 |
| 5 | Karmiotissa Pano Polemidion | 6975.0 |
| 6 | CR Belouizdad | 6575.0 |
| 7 | US Triestina | 6225.0 |
| 8 | Aris Limassol | 6102.5 |
| 9 | Rubin Kazan | 6076.2 |
plt.figure(figsize=(15, 7))
plt.bar(x= rich_club.new_club , height= rich_club.cost)
plt.xlabel( "Club", fontsize = 20 , fontweight = "bold")
plt.ylabel( "Sum of Costs", fontsize = 20 , fontweight = "bold")
plt.xticks(rotation= 90)
for i in range(len(rich_club.new_club)):
plt.text(i , rich_club.cost[i] , rich_club.cost[i] ,
ha= "center" ,
va= "bottom" ,
fontsize = "12" ,
fontweight = "bold")
plt.show()
plt.figure(figsize=(20, 7))
plt.subplot(1, 2, 1)
plt.bar(x= index , height= values)
plt.xlabel( "Club", fontsize = 20 , fontweight = "bold")
plt.ylabel( "Count of buying Players", fontsize = 20 , fontweight = "bold")
plt.xticks(rotation= 90)
for i in range(len(index)):
plt.text(i , values[i] , values[i] ,
ha= "center" ,
va= "bottom" ,
fontsize = "12" ,
fontweight = "bold")
plt.subplot(1, 2, 2)
plt.bar(x= rich_club.new_club , height= rich_club.cost)
plt.xlabel( "Club", fontsize = 20 , fontweight = "bold")
plt.ylabel( "Sum of Costs", fontsize = 20 , fontweight = "bold")
plt.xticks(rotation= 90)
for i in range(len(rich_club.new_club)):
plt.text(i , rich_club.cost[i] , rich_club.cost[i] ,
ha= "center" ,
va= "bottom" ,
fontsize = "12" ,
fontweight = "bold")
new_df = pd.DataFrame(df.cost.sort_values(ascending= False))
new_df["name"] = df.name
new_df["club"] = df.new_club
new_df = new_df[:10]
new_df
| cost | name | club | |
|---|---|---|---|
| 19501 | 950.0 | Kazimcan Karatas | Galatasaray A.S. |
| 24337 | 925.0 | Sem Steijn | Twente Enschede FC |
| 9891 | 925.0 | Kuni | Casa Pia AC |
| 7784 | 900.0 | Adrian Rus | Pisa Sporting Club |
| 15971 | 900.0 | Julien Célestine | Club León FC |
| 3986 | 900.0 | Charly Musonda Jr. | Levante UD |
| 9283 | 900.0 | Ygor Nogueira | Esporte Clube Juventude |
| 2504 | 900.0 | Ramón Martínez | Grêmio Novorizontino (SP) |
| 26765 | 900.0 | Matej Maglica | FC St. Gallen 1879 |
| 16033 | 900.0 | Martin Ádám | Ulsan Hyundai |
fig = px.line(new_df, x="name", y="cost", title='Expensive Deals')
fig.show()
df.head()
| name | position | age | origin_club | league_origin_club | country_origin_club | new_club | league_new_club | country_new_club | cost | month | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Amine Gouiri | Centre-Forward | 22.0 | OGC Nice | Ligue 1 | France | Stade Rennais FC | Ligue 1 | France | 42.0 | Sep |
| 1 | Umar Sadiq | Centre-Forward | 25.0 | UD Almería | LaLiga | Spain | Real Sociedad | LaLiga | Spain | 18.0 | Sep |
| 2 | Carlos Soler | Central Midfield | 25.0 | Valencia CF | LaLiga | Spain | Paris Saint-Germain | Ligue 1 | France | 50.0 | Sep |
| 3 | Manuel Akanji | Centre-Back | 27.0 | Borussia Dortmund | Bundesliga | Germany | Manchester City | Premier League | England | 30.0 | Sep |
| 4 | Wout Faes | Centre-Back | 24.0 | Stade Reims | Ligue 1 | France | Leicester City | Premier League | England | 10.0 | Sep |
df.origin_club.unique()
df.origin_club.nunique()
5601
sort = df.groupby("origin_club").cost.sum().sort_values(ascending= False)
sort2 = df.groupby("origin_club").name.count().sort_values(ascending= False)
sort , sort2
(origin_club
Atalanta BC 10013.2
US Salernitana 1919 8305.5
CFR Cluj 8062.7
Frosinone Calcio 7479.0
LASK 7328.0
...
Sporting CP U19 1.0
Bayer 04 Leverkusen U19 1.0
Real Madrid U19 1.0
Incheon United 1.0
Atlas Guadalajara U20 1.0
Name: cost, Length: 5601, dtype: float64,
origin_club
Atalanta BC 56
Genoa CFC 39
US Sassuolo 35
Juventus Next Gen 31
Inter Milan 30
..
NK Radomlje U19 1
Bangladesh Police FC 1
Cusco FC 1
NK Rudar Velenje U19 1
Boldklubben af 1893 1
Name: name, Length: 5601, dtype: int64)
new_df = pd.DataFrame(sort.index)
new_df["money"] = sort.values
new_df["C_players"] = sort2.values
new_df = new_df[:10]
new_df
| origin_club | money | C_players | |
|---|---|---|---|
| 0 | Atalanta BC | 10013.2 | 56 |
| 1 | US Salernitana 1919 | 8305.5 | 39 |
| 2 | CFR Cluj | 8062.7 | 35 |
| 3 | Frosinone Calcio | 7479.0 | 31 |
| 4 | LASK | 7328.0 | 30 |
| 5 | Juventus Next Gen | 6991.9 | 28 |
| 6 | GNK Dinamo Zagreb | 6949.0 | 28 |
| 7 | Spartak 2 Moscow ( -2022) | 6850.0 | 27 |
| 8 | FC Sion | 6550.0 | 26 |
| 9 | Real Valladolid CF | 6457.5 | 26 |
fig = px.bar(new_df, x='origin_club', y='money',
hover_data=['C_players', 'money'], color='money',
labels= 'money', height=500,
title= "Top 10 Origin Clubs Received Most Deals py count of players")
fig.show()